function hd_ajax(e, t, n, a) {
	var a = a || 2;
	$.ajax({
		url: e,
		data: t,
		type: "POST",
		dataType: "json",
		success: function(e) {
			hd_alert({
				message: e.message,
				timeout: a,
				success: function() {
					e.status && n && (location.href = n)
				}
			})
		}
	})
}

function hd_submit(e, t, n, a) {
	var a = a || 2;
	return $(e).data("isPost") || ($(e).data("isPost", 1), $.ajax({
		url: t,
		data: $(e).serialize(),
		type: "POST",
		dataType: "json",
		success: function(t) {
			hd_alert({
				message: t.message,
				timeout: a,
				success: function() {
					t.status && n && (location.href = n)
				}
			}), $(e).removeData("isPost")
		}
	})), !1
}

function hd_alert(e) {
	e.timeout = e.timeout || 3, hd_alert_close();
	var t = '<div id="hd-alert">' + e.message + "</div>";
	$("body").append(t), $("#hd-alert").animate({
		top: "-30px"
	}, 500).delay(1e3 * e.timeout).animate({
		top: "-100px"
	}, 500, "", function() {
		e.success && e.success()
	})
}

function hd_alert_close() {
	$("#hd-alert").remove()
}

function hd_confirm(e) {
	e.title = e.title || "温馨提示", e.message = e.message || "这是提示信息", hd_confirm_success_handlel = e.success, hd_confirm_cancel_handle = e.cancel, hd_confirm_close();
	var t = '<div id="hd-confirm-bg">背景遮罩</div>    <div id="hd-confirm">    <div class="hd-confirm-header">        <span class="hd-confirm-title">' + e.title + '</span>        <span class="hd-confirm-close" onclick="hd_confirm_close();"></span>    </div>    <div class="hd-confirm-message">' + e.message + '</div>        <div class="hd-confirm-btn">            <a class="hd-btn hd-btn-success" href="javascript:;" onclick="hd_confirm_success()">确 定</a>&nbsp;&nbsp;            <a class="hd-btn" href="javascript:;" onclick="hd_confirm_close()">关 闭</a>        </div>    </div>';
	$("body").append(t)
}

function hd_confirm_success() {
	return $("#hd-confirm").remove(), $("#hd-confirm-bg").remove(), hd_confirm_success_handlel && hd_confirm_success_handlel(), !0
}

function hd_confirm_close() {
	return $("#hd-confirm").remove(), $("#hd-confirm-bg").remove(), hd_confirm_cancel_handle && hd_confirm_cancel_handle(), !1
}

function hd_select_all(e) {
	$(e).find($("[type='checkbox']")).attr("checked", "checked")
}

function hd_reverse_select(e) {
	$(e).find($("[type='checkbox']")).attr("checked", function() {
		return 1 == !$(this).attr("checked")
	})
}

function hd_modal(e) {
	e.width = e.width || "500", e.height = e.height || "200";
	var t = -1 * e.width / 2;
	if (e.title = e.title || "温馨提示", e.shade = void 0 != e.shade ? e.shade : !0, e.shadeOpacity = e.shadeOpacity || .9, e.timeout = e.timeout || 0, e.button = void 0 != e.button ? e.button : !0, e.button_success = e.button_success, e.button_cancel = e.button_cancel, e.content = e.content || "", hd_modal_success_handlel = e.success, hd_modal_cancel_handle = e.cancel, hd_remove_model(), e.button) {
		var n = '<div class="hd-modal-btn">';
		e.button_success && (n += '<a class="hd-btn hd-btn-success" href="javascript:;" onclick="hd_modal_success()">' + e.button_success + "</a>&nbsp;"), e.button_cancel && (n += '<a class="hd-btn" href="javascript:;" onclick="hd_modal_close()">' + e.button_cancel + "</a>"), n += "</div>"
	} else var n = "";
	shadeHtml = e.shade ? '<div id="hd-modal-bg" style="opacity:' + e.shadeOpacity + ";filter:alpha(opacity=" + 10 * e.shadeOpacity + ');">背景遮罩</div>' : "";
	var a = shadeHtml + '    <div id="hd-modal" style="width:' + e.width + "px;height:" + e.height + "px;margin-left:" + t + 'px">        <div class="hd-modal-wrap" style="height:' + e.height + 'px">            <div class="hd-modal-header">                <span class="hd-modal-title">' + e.title + '</span>                <span class="hd-modal-close" onclick="hd_modal_close();"></span>            </div>            <div class="hd-modal-message">' + e.content + "</div>            " + n + "        </div>    </div>";
	$("body").append(a), e.timeout > 0 && setTimeout(function() {
		hd_remove_model()
	}, 1e3 * e.timeout)
}

function hd_remove_model() {
	$("#hd-modal").remove(), $("#hd-modal-bg").remove()
}

function hd_modal_success() {
	return hd_remove_model(), hd_modal_success_handlel && hd_modal_success_handlel(), !0
}

function hd_modal_close() {
	return hd_remove_model(), hd_modal_cancel_handle && hd_modal_cancel_handle(), !1
}
var hd_confirm_success_handlel, hd_confirm_cancel_handle, cookie = {
		set: function(e, t, n) {
			var a = new Date;
			a.setDate(a.getDate() + n), document.cookie = e + "=" + t + ";expires=" + a
		},
		get: function(e) {
			for (var t = document.cookie.split("; "), n = t.length - 1; n >= 0; n--) {
				var a = t[n].split("=");
				if (a[0] === e) return a[1]
			}
			return ""
		},
		del: function(e) {
			cookie.set(e, 1, -1)
		}
	},
	hd_modal_success_handlel, hd_modal_cancel_handle;
$.fn.extend({
	slide: function(e) {
		function t(t) {
			s = void 0 != t ? t : s;
			var n = e.alink.eq(s);
			n.show(), e.alink.not(n).hide();
			var a = e.alink.eq(s).attr("title"),
				i = e.alink.eq(s).attr("href"),
				c = "<a style='text-decoration:none;color:" + e.textColor + ";' href='" + i + "'>" + a + "</a>";
			$("#_slideText").html("<div style='font-size:12px;line-height: 30px;text-indent: 10px;'>" + c + "</div>"), $("#_slideNum li").css({
				background: "#fff",
				color: "#333",
				"list-style": "none",
				"font-size": "12px"
			}), $("#_slideNum li").eq(s).css({
				background: "#FF7F00",
				color: "#fff"
			}), s = s + 1 >= e.num ? 0 : s + 1
		}
		_bgcolor = e.bgcolor ? e.bgcolor : "#333", e.bgopacity = e.bgopacity || .9, e.textColor = e.textColor || "#ddd", e.timeout = e.timeout || 3, e.alink = $(this).find("a"), e.num = e.alink.length, $(this).css({
			width: e.width,
			height: e.height,
			overflow: "hidden",
			position: "relative"
		}), e.alink.hide(), e.alink.eq(0).show();
		var n = "<div id='_slideText' style='height: 30px;background:" + _bgcolor + ";color:#fff;position: absolute;left: 0px;right: 0px;bottom: 0px;'></div>";
		$(this).append(n), $("#_slideText").css({
			opacity: e.bgopacity
		});
		for (var a = "<div id='_slideNum' style='position: absolute;height: 18px;bottom: 6px;right: 0px;'>", i = 1; e.num >= i; i++) a += "<li style='float: left;opacity:0.8;border-radius:50%;cursor:pointer;color:#333;width: 18px;height: 18px;background: #fff;margin-right: 6px;text-align: center;line-height: 1.5em;'>" + i + "</li>";
		a += "</div>", $(this).append(a);
		var s = 0;
		setInterval(t, 1e3 * e.timeout), t(0), $("#_slideNum li").mouseover(function() {
			var e = $(this).index();
			t(e)
		})
	}
}), $(function() {
	$("div.hd-tab ul.hd-tab-menu li").click(function() {
		$("div.hd-tab-content").children("div").hide();
		var e = $(this).attr("lab");
		$("div.hd-tab-content div[lab='" + e + "']").show(), $("div.hd-tab ul.hd-tab-menu li").removeClass("active"), $("div.hd-tab ul.hd-tab-menu li[lab='" + e + "']").addClass("active")
	})
}), $.fn.extend({
	validate: function(e) {
		var t = $(this);
		t.failure = [], t.ajaxNum = 0, t.on("submit", function(e) {
			t.firstSubmit || (t.find("input,textarea,select").trigger("change"), t.firstSubmit = !0), (t.failure.length || 0 != t.ajaxNum) && e.preventDefault()
		});
		var n = {
				required: function(e, t, n) {
					return "" != n
				},
				email: function(e, t, n) {
					return /^([a-zA-Z0-9_\-\.])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/i.test(n)
				},
				http: function(e, t, n) {
					return /^(http[s]?:)?(\/{2})?([a-z0-9]+\.)?[a-z0-9]+(\.(com|cn|cc|org|net|com.cn))$/i.test(n)
				},
				phone: function(e, t, n) {
					return /^\d{11}$/.test(n)
				},
				qq: function(e, t, n) {
					return /^\d{5,10}$/.test(n)
				},
				tel: function(e, t, n) {
					return /(?:\(\d{3,4}\)|\d{3,4}-?)\d{8}/.test(n)
				},
				identity: function(e, t, n) {
					return /^(\d{15}|\d{18})$/.test(n)
				},
				china: function(e, t, n) {
					return /^([^u4e00-u9fa5]|\w)+$/i.test(n)
				},
				maxlen: function(e, t, n, a) {
					return a >= n.length
				},
				minlen: function(e, t, n, a) {
					return n.length >= a
				},
				num: function(e, t, n, a) {
					return opt = a.split(/\s*,\s*/), n >= 1 * opt[0] && 1 * opt[1] >= n
				},
				regexp: function(e, t, n, a) {
					return a.test(n)
				},
				confirm: function(e, t, n, a) {
					var i = $("[name='" + a + "']");
					return i.change(function() {
						e.trigger("change")
					}), n == i.val()
				},
				ajax: function(e, n, i, s, c, d) {
					t.ajaxNum += 1;
					var o = s.data ? s.data : {};
					return o[n] = i, $.ajax({
						url: s.url,
						data: o,
						type: "POST",
						dataType: "JSON",
						success: function(i) {
							t.ajaxNum -= 1;
							var s = i.status ? !0 : !1;
							a.setSpanMessage(s, e, n, i.message, i.message), a.recordVerificationResult(s, n)
						},
						error: function() {
							a.setSpanMessage(!1, e, n, c, d), a.recordVerificationResult(!1, n)
						}
					}), "run"
				}
			},
			a = {
				__construct: function() {
					this.bindHandler()
				},
				bindHandler: function() {
					for (var t in e) {
						var n = this.getFieldObj(t);
						n && (this.setSpanDefaultMessage(n, t), this.bindExeAction(n, t))
					}
				},
				bindExeAction: function(i, s) {
					var c = this.getEventName(i);
					t.find(i).on(c, {
						obj: i,
						name: s
					}, function(t) {
						var i = t.data.obj,
							s = t.data.name,
							c = e[s].rule,
							d = a.getFieldValue(i);
						if (c.required || d)
							for (var o in c) {
								var r = e[s].success,
									l = e[s].error ? e[s].error[o] : null,
									h = n[o](i, s, d, c[o], r, l);
								if (a.setSpanMessage(h, i, s, r, l), a.recordVerificationResult(h, s), 0 == h) break
							} else a.hideSpanObj(i, s)
					})
				},
				recordVerificationResult: function(e, n) {
					"run" == e || (e ? t.failure = $.grep(t.failure, function(e) {
						return e != n
					}) : (t.failure = $.grep(t.failure, function(e) {
						return e != n
					}), t.failure.push(n)))
				},
				getFieldValue: function(e) {
					var t = e.attr("type"),
						n = "";
					return n = "radio" == t || "checkbox" == t ? e.filter("[checked]").val() : e.val(), void 0 != n || "" != $.trim(n) ? n : ""
				},
				getEventName: function() {
					return "change"
				},
				getFieldObj: function(e) {
					var t = $("[name='" + e + "']");
					return 0 == t.length ? !1 : t
				},
				setSpanDefaultMessage: function(t, n) {
					if (e[n].message) {
						var i = a.addSpanObj(t, n);
						i.removeClass().addClass("hd-validate-notice").html(e[n].message)
					}
				},
				setSpanMessage: function(e, t, n, i, s) {
					a.hideSpanObj(t, n), "run" === e || (e ? i && a.addSpanObj(t, n).removeClass().addClass("hd-validate-success").html(i) : s && a.addSpanObj(t, n).removeClass().addClass("hd-validate-error").html(s))
				},
				hideSpanObj: function(e, t) {
					return $("#hd_" + t).css("display", "none")
				},
				addSpanObj: function(e, t) {
					var n = "#hd_" + t;
					if (0 == $(n).length) {
						var a = "<span id='hd_" + t + "'></span>";
						e.last().after(a)
					}
					return $(n).css("display", "inline-block")
				}
			};
		a.__construct()
	}
});